package com.lottery.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class BaseController {

    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
   /**
     * 解析json
     *
     * @param request
     * @return
     * @throws IOException
     */
    protected String readHttpBody(HttpServletRequest request) throws IOException {

        // 读取input流
        /*
         * BufferedReader br = new BufferedReader( new
         * InputStreamReader((ServletInputStream) request.getInputStream(), "utf-8"));
         * StringBuffer sb = new StringBuffer(""); String temp; while ((temp =
         * br.readLine()) != null) { sb.append(temp); } br.close(); return
         * sb.toString();
         */

        String attribute = (String) request.getAttribute("json");
        return attribute;
    }
}
